package org.ece3574.WTParty;


import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.Toast;

public class PartyInfoActivity extends Activity implements OnClickListener{
	
	//private float rateval_;
    //private RatingBar mSmallRatingBar;
    private RatingBar mIndicatorRatingBar;
    //private TextView mRatingText;
	private Button favButton_;
	private Button rateButton_;
	private Button callButton_;
	private Button imgButton_;
	//private Button whoButton_;
	private Button postButton_;
	//private Button readButton_;
	private Button mapButton_;
	//private Context mContext; 
	private Dialog alertDialog;
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.partyinfo);
		
		//mContext = getApplicationContext();

		favButton_ = (Button)findViewById(R.id.FButton);
		rateButton_ = (Button)findViewById(R.id.mratingButton);
		callButton_ = (Button)findViewById(R.id.callButton);
		imgButton_ = (Button)findViewById(R.id.ImageButton);
		//whoButton_ = (Button)findViewById(R.id.whoButton);		
		postButton_ = (Button)findViewById(R.id.mCommentButton);
		//readButton_ = (Button)findViewById(R.id.readButton);  
		mapButton_ = (Button)findViewById(R.id.mapButton);
		//mSmallRatingBar = (RatingBar)findViewById(R.id.ratingbar_Indicator);
		mIndicatorRatingBar = (RatingBar)findViewById(R.id.ratingbar_default);

		
		favButton_.setOnClickListener(this);
		rateButton_.setOnClickListener(this);
		callButton_.setOnClickListener(this);
		imgButton_.setOnClickListener(this);
		//whoButton_.setOnClickListener(this);
		postButton_.setOnClickListener(this);
		//readButton_.setOnClickListener(this);
		mapButton_.setOnClickListener(this);
		
		mIndicatorRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){	
		public void onRatingChanged(RatingBar ratingBar, float rating,
				     boolean fromUser) {
				    // TODO Auto-generated method stub
					   CalculateRate(rating);
					   mIndicatorRatingBar.setVisibility(4);
					}});
		

	}
	
	

public void CalculateRate(float rating){
	// to be implemented waiting on the server side
}





	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v.equals(postButton_)){

			//final EditText inputName = new EditText(this);
			/*AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
			alertDialogBuilder.setTitle("Post a Comment");
			alertDialogBuilder
			.setMessage("Click submit to post!")
			.setCancelable(true);
			.setNegativeButton("submit",new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog,int id) {
					// if this button is clicked, just close
					// the dialog box and do nothing
					dialog.cancel();
				}
			}).setView(inputName);

			// create alert dialog
			AlertDialog alertDialog = alertDialogBuilder.create();*/

			// show it
			alertDialog = new Dialog(PartyInfoActivity.this);
			alertDialog.setContentView(R.layout.writecomment);
			alertDialog.setTitle("Leave a Comment");
			//final EditText commentArea_ = (EditText) findViewById(R.id.postComment);
			//final Button submit1_ = (Button) findViewById(R.id.SubmitButton);
			/*submit_.setOnClickListener(new OnClickListener() {
				
				public void onClick(View v) {
					// TODO Auto-generated method stub
					String comment = commentArea_.getText().toString().trim();
					alertDialog.dismiss();
					
				}
			});*/
			alertDialog.show();
		}else if(v.equals(mapButton_)){
			Intent i = new Intent(v.getContext(), MapScreenActivity.class);
			startActivity(i);
			
		}else if(v.equals(favButton_)){
			Toast t = Toast.makeText(this, "Added To Your Favorite List", 3000);
			t.show();
			//String favURL_ = "http://wtparty.overstrom.net/"; get the url of where the server where the favorite party gonna be stored
			// handle and format the information to be sent
			//use doGet to post on server;
			
		}
		//clicking the pictures button will invoke the camera app
		else if(v.equals(imgButton_)){
			Intent intent  = new Intent(PartyInfoActivity.this, AndroidCamera.class);
			startActivity(intent);
			}
		}
	
	// In this class the information will be parsed from the server using json and gson

}
